# coding=utf-8
# 代码文件：client/ui/request_gridtable.py

"""自定义 GridTableBase 类，用于请求网格"""
import wx.grid

# 请求网格列名
COLUMN_NAMES = ['文档Id', '中文名', '价值点数']


class RequestGridTable(wx.grid.GridTableBase):
    def __init__(self, data):
        super().__init__()
        self.colLabels = COLUMN_NAMES
        self.data = data

    def GetNumberRows(self):
        return len(self.data)

    def GetNumberCols(self):
        return len(COLUMN_NAMES)

    def GetValue(self, rowidx, colidx):
        file = self.data[rowidx]
        if colidx == 0:
            return file['fileid']
        elif colidx == 1:
            return file['cname']
        else:
            return file['points']

    def GetColLabelValue(self, colidx):
        return self.colLabels[colidx]
